//E收益

 $(function (){ 
 $(".top1_list .top1_body").hide();
         $(".main").hide();
	$("#gouwu_content").show();
 
	
		
		
//初始化顶部导航

//注册函数
$("#register").click(function(){

 $.ajax({
			type:"POST",
			url:url+"/register",
		    data:{username:$('#username').val(),userpassword:$('#userpassword').val(),useremail:$('#useremail').val()},
			dataType:"json",
			error:function (XMLHttpRequest, textStatus, errorThrown) {alert('请求错误...'+errorThrown);},
			success:function(data){ 
			  alert(data.data);
			   location.reload();
			 
				 
			        }
		              });

});
//登陆函数
$("#login").click(function(){

 $.ajax({
			type:"POST",
			url:url+"/login",
		    data:{username:$('#username').val(),userpassword:$('#userpassword').val(),useremail:$('#useremail').val()},
			dataType:"json",
			error:function (XMLHttpRequest, textStatus, errorThrown) {alert('请求错误...'+errorThrown);},
			success:function(data){ 

			   
			   location.reload();
				 
			        }
		              });

});
//去购物函数

$("#top2_gouwu").click(function(){
sctype="qbsj";
getmall(sctype);
$(".main").hide();
$("#gouwu_content").show();
  $("#gouwu_content ul:visible").hide();
  $("#gouwu_content ul").filter("#"+sctype).show();
getusermall_order(sctype);
getmall_order(sctype);
$(".main").hide();
$("#gouwu_content").show();
  $("#gouwu_content ul:visible").hide();
  $("#gouwu_content ul").filter("#"+sctype).show();
});
$("#top2_baobiao").click(function(){

$(".main").hide();
$("#baobiao").show();
});
$("#top2_shouyi").click(function(){

$(".main").hide();
$("#shouyi").show();
});
$("#top2_xfenlei").click(function(){
$(".main").hide();
$("#gouwu_menu").show();
$("#gouwu_content").show();
});
$("#top2_tjsc").click(function(){
sctype="rmsj";
$(".main").hide();
$("#gouwu_content").show();
  $("#gouwu_content ul:visible").hide();
  $("#gouwu_content ul").filter("#"+sctype).show();

});
$("#top2_wyinyong").click(function(){
$("#gouwu_menu").hide();
$(".main").hide();
$("#wyinyong").show();
});

getusermall_order(sctype);
getmall_order(sctype);
	
$("#gouwu_content ul:eq(1)").hide();

//购物导航函数
$("#gouwu_menu .menu_item").each( function(i,val){
$(this).click( function(){
  
        getmall($(this).attr('id'));
        $(".main").hide();
        $("#gouwu_content").show();
        $("#gouwu_content ul:visible").hide();
        $("#gouwu_content ul").filter("#"+$(this).attr('id')).show();
        getmall_order($(this).attr('id'));
		getusermall_order($(this).attr('id'));			

  
	 
});
});
function getmall(id)
{
  if($("#gouwu_content ul").is("#"+id)==false) { 
      var gouwu_content=$("#gouwu_content").get(0);
	  var newNode = document.createElement("ul");
	      newNode.id=id;
	  /*
   $("#gouwu_content").append("<ul id='"+id+"'>");
    $.each($.treedb.getdblevel(url+"/getmall",id),function(j,val){
          
		 $("#gouwu_content ul:last").append("<li><div class='block'><span>"+val['name']+"</span><span><a href='"+val['url']+userid1+"'><img src='"+val['img']+"'/></a></span></div></li>");
		});
			   $("#gouwu_content").append("</ul>");	 
			}
		*/
$.each($.treedb.getdblevel(url+"/getmall",id),function(j,val){
          
		 newNode.innerHTML+="<li><div class='block'><span>"+val['name']+"</span><span><a href='"+val['url']+userid1+"'><img src='"+val['img']+"'/></a></span></div></li>";
		});
			   gouwu_content.appendChild(newNode);	 
			}		
			
}

function getusermall_order(id)
{
			$.ajax({
			type:"POST",
			url:url+"/getusermall_order", 
			data:{id:id},
			dataType:"json",
			error:function (XMLHttpRequest, textStatus, errorThrown) {alert('请求错误...'+errorThrown);},
			success:function(data){ 
				$("#maingrid1").ligerGrid({
                columns: [
				{ display: '商城名称', name: 'mallname', minWidth: 100 },
				{ display: '收益比例', name: 'sybl', minWidth: 50},
                { display: '购物金额', name: 'sales', minWidth: 100 },
			    { display: '总收益', name: 'commission', minWidth: 100 },
                { display: '购物收益', name: 'gusy', width: 100, align: 'left' },
				{ display: '业务收益', name: 'ywsy', width: 100, align: 'left' },
				{ display: '分红收益', name: 'fhsy', width: 100, align: 'left' },
				{ display: '商城标志', name: 'mallimg', minWidth: 140 },
			   { display: '去购物赚收益', name: 'mallurl', minWidth: 140 },
			   { display: '业务链接', name: 'ywurl', minWidth: 180 }
                ], data:eval('(' + data.data + ')') , pageSize: 10, sortName: 'riqi',width:'100%',
             rowHeight:60,height: 680, checkbox: false
            });	  
			        }
		              });

				    }
$float_speed=1500; //milliseconds
$float_easing="easeOutQuint";
$menu_fade_speed=500; //milliseconds
$closed_menu_opacity=0.75;

//cache vars
 $fl_menu=$("#fl_menu");


	menuPosition=$('#fl_menu').position().top;
	 

$(".virtual_body").scroll(function () { 
	var scrollAmount=$(".virtual_body").scrollTop();

	var newPosition=menuPosition+scrollAmount;
		$fl_menu.css("top",newPosition);	
     $fl_menu.stop().animate({top: menuPosition}, $float_speed, $float_easing);
	
});


					});